#pragma once
#include "Runtime/CGI/CGICommandList.h"
#include "RenderGraphPass.h"
namespace Alice{
    class RDGBuilder
    {
    public:
        CGICommandListScopedExtendResourceLifetime mExtendResourceLifetimeScope;
        std::vector<RDGDispatchPass*> mDispatchPasses;
        RDGBuilder(CGICommandListImmediate& RHICmdList);
        /** Adds a pass that takes a FRDGDispatchPassBuilder instead of a RHI command list. The lambda should create command lists
         *  and launch tasks to record commands into them. Each task should call EndRenderPass() (if raster) and FinishRecording()
         *  to complete each command list. The user is responsible for task management of dispatched command lists.
         */
        template <typename ParameterStructType, typename LaunchLambdaType>
        RDGPass* AddDispatchPass(const ParameterStructType* ParameterStruct, ERDGPassFlags Flags, LaunchLambdaType&& LaunchLambda)
        {
            using DispatchPassType = TRDGDispatchPass<ParameterStructType, LaunchLambdaType>;
            RDGDispatchPass*pass=new DispatchPassType(ParameterStruct,Flags,std::forward<LaunchLambdaType&&>(LaunchLambda));
            mDispatchPasses.push_back(pass);
            return pass;
        }
        void SetupDispatchPassExecute();
        void Execute();
    };
}
